﻿using System;
using System.Collections.Generic;

namespace SimpleORM
{
    public class FromNameDictionary : Dictionary<Type, string>
    {
        #region Fields

        private int indexFrom = 0;
        private string fromFormat = string.Empty;

        private static readonly Random rd = new Random((int)DateTime.Now.Ticks);

        #endregion

        #region Ctor

        public FromNameDictionary()
        {
            //fromFormat = string.Format("t{0}", rd.Next(short.MaxValue).ToString("X"));
            //fromFormat += "{0}";
            fromFormat = "t{0}";
        }

        #endregion

        #region Methods

        #region Methods - Public

        public string Set(Type fromType)
        {
            string aliasName = string.Format(fromFormat, indexFrom++);

            this[fromType] = aliasName;

            return aliasName;
        }

        public string Get(Type fromType)
        {
            return this[fromType];
        }

        #endregion

        #endregion
    }
}
